import { getUserInfoAPI } from '@/api'
import type { H5AreaData } from '@/types'
import type { ProfileInfo } from '@/types/user'
import { onMounted, ref } from 'vue'

export const useUserInfo = () => {
  const userInfo = ref<ProfileInfo>({
    account: '',
    avatar: '',
    birthday: '',
    fullLocation: '',
    gender: '男',
    id: '',
    nickname: '',
    profession: '',
    provinceCode: '',
    cityCode: '',
    countyCode: '',
  })
  onMounted(() => {
    getUserInfo()
  })
  const getUserInfo = async () => {
    userInfo.value = await getUserInfoAPI()
  }
  return { userInfo }
}

//地区列表数据
export const useAreaData = () => {
  const cityData = ref<H5AreaData>()
  onMounted(() => {
    getAreaList()
  })
  const getAreaList = async () => {
    cityData.value = await window.hdm.getAreaList()
  }
  return { cityData }
}
